package org.gaaidou.ptarmigan.springboot.idworker;

import org.gaaidou.ptarmigan.springboot.distributed.WorkerIdService;
import org.gaaidou.ptarmigan.springboot.idworker.impl.SnowflakeIdWorker;
import org.gaaidou.ptarmigan.springboot.idworker.impl.UuidWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IdWorkerConfig {

    @Autowired
    private WorkerIdService workerIdService;

    @Bean
    public IdWorker<Long> snowflakeIdWorker() {
        return new SnowflakeIdWorker(workerIdService.workId());
    }

    @Bean
    public IdWorker<String> uuidWorker() {
        return new UuidWorker();
    }
}
